package sch.frog.creational.builderpattern;

import sch.frog.creational.builderpattern.builder.AProductBuilder;
import sch.frog.creational.builderpattern.builder.BProductBuilder;
import sch.frog.creational.builderpattern.builder.Builder;
import sch.frog.creational.builderpattern.product.IProduct;

public class BuilderPatternDemo {

    public static void main(String[] args){
        // 构建产品A
        Builder builderA = new AProductBuilder().setName("A").setValue(12);
        IProduct productA = new Director(builderA).construct();

        // 构建产品B
        Builder builderB = new BProductBuilder().setName("B").setValue(20);
        IProduct productB = new Director(builderB).construct();


        System.out.println("----A----");
        userProduct(productA);


        System.out.println("----B----");
        userProduct(productB);
    }

    public static void userProduct(IProduct product){
        System.out.println(product.getName() + " - " + product.getValue());
        product.getPartTwo().getPartOne().one();
    }

}
